﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using Core.Messages;
using Library.Logging;
using PostSharp.Aspects;
using System.Transactions;

namespace Core.Aspects
{
    [Serializable]
    public class TransactionAttribute : MethodInterceptionAspect
    {
        public override void OnInvoke(MethodInterceptionArgs args)
        {
            TransactionScope transaction = new TransactionScope();
            try
            {
                args.Proceed();
                transaction.Complete();
            }
            finally
            {
                transaction.Dispose();
            }     
        }
    }    
}
